package bamin.com.bamindaijia.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.List;

import bamin.com.bamindaijia.R;
import bamin.com.bamindaijia.model.MessageList;
import bamin.com.bamindaijia.model.User;

/**
 * 充值记录
 */
public class MyMessageAdapter extends BaseAdapter {
    private final LayoutInflater inflater;
    private List<MessageList.DatasBean> rechargeLogContains;
    private User mUser;

    public MyMessageAdapter(Context context, List<MessageList.DatasBean> rechargeLogContains) {
        inflater = LayoutInflater.from(context);

        this.rechargeLogContains = rechargeLogContains;
    }

    class ViewHolder {
        TextView textView_content;
        TextView textView_Time;
        TextView textView_title;
    }

    @Override
    public int getCount() {
        return rechargeLogContains.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_message, null);
            holder.textView_content = (TextView) convertView.findViewById(R.id.textView_content);
            holder.textView_Time = (TextView) convertView.findViewById(R.id.textView_Time);
            holder.textView_title = (TextView) convertView.findViewById(R.id.textView_title);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        MessageList.DatasBean datasBean = rechargeLogContains.get(position);

        holder.textView_content.setText(datasBean.getMessage());
        holder.textView_Time.setText(datasBean.getTime());
        holder.textView_title.setText(datasBean.getTitle());
        return convertView;
    }
}